package com.hzhr.iot.cqgas.ds.service;

import com.hzhr.iot.cqgas.ds.dao.user.example.UsrOptionsDao;
import com.hzhr.iot.cqgas.ds.entity.user.UsrOptionsEntity;
import com.hzhr.iot.cqgas.ds.entity.user.UsrOptionsExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UsrOptionsService {
    @Autowired
    UsrOptionsDao usrOptionsDao;

    public String getCode(String typeName, String name) {
        UsrOptionsExample usrOptionsExample = new UsrOptionsExample();
        usrOptionsExample.createCriteria()
                .andTypeNameEqualTo(typeName)
                .andNameEqualTo(name);
        List<UsrOptionsEntity> usrOptionsEntities = usrOptionsDao.selectByExample(usrOptionsExample);
        if (usrOptionsEntities.size() == 0) return null;
        return usrOptionsEntities.get(0).getCode();
    }
}
